﻿/////////////////////////////////////////////////////////////////////////
//                                                                     //
//    MTGProject - A Magic The Gathering Networked Environment         //
//                                                                     //
//        Copyright (c) 2008 by The MTGProject Team (CSC230)           //
//                                                                     //
// This file is part of MTGProject.                                    //
//                                                                     //
// MTGProject is free software; you can redistribute it and/or         //
// modify it under the terms of the GNU Lesser General Public          //
// License as published by the Free Software Foundation; either        //
// version 3 of the License, or (at your option) any later version.    //
//                                                                     //
// This library is distributed in the hope that it will be useful,     //
// but WITHOUT ANY WARRANTY; without even the implied warranty of      //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       //
// GNU Lesser General Public License for more details.                 //
//                                                                     //
// You should have received a copy of the GNU Lesser General Public    //
// License along with this library; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA           //
// 02111-1307, USA, or contact the author(s):                          //
//                                                                     //
// Ruben Acuna <flyingfowlsoftware@earthlink.net>                      //
//                                                                     //
/////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;

namespace MTGProject
{
    class UtilDebug
    {
        static public void printPlayer(Player player)
        {
            System.Console.WriteLine("------------ " + player.Name + " @ " + player.Health + " ----------");

            System.Console.WriteLine("Permanents (" + player.Permanents.Cards.Count + " cards):");
            printCards(player.Permanents);

            System.Console.WriteLine("Hand (" + player.Hand.Cards.Count + " cards):");
            printCards(player.Hand);

            System.Console.WriteLine("Deck (" + player.Deck.Cards.Count + " cards):");
            //printCards(player.Deck);

            System.Console.WriteLine("Graveyard (" + player.Graveyard.Cards.Count + " cards):");
            printCards(player.Graveyard);

            System.Console.WriteLine("Mana Pool (" + player.ManaPool.Count + " floating):");
            foreach (ManaColor mana in player.ManaPool)
                System.Console.WriteLine(mana.ToString());

            System.Console.WriteLine("----------------------------------");
            System.Console.WriteLine("");

        }

        static public void printCards(CardPool deck)
        {
            ICard[] cards = new ICard[deck.Cards.Count];
            deck.Cards.CopyTo(cards, 0);

            for (int x = 0; x < deck.Cards.Count; x++)
            {
                System.Console.Write("  " + (x + 1) + ") " + cards[x].Name);

                System.Console.Write(" (" + ManaList(cards[x].Cost) + ")");

                if (cards[x] is IPermanent)
                    System.Console.WriteLine("  Tapped: " + ((IPermanent)cards[x]).IsTapped);
                else
                    System.Console.WriteLine("");
            }
        }

        static string ManaList(LinkedList<ManaColor> linkedList)
        {
            string textList = "";

            foreach (ManaColor color in linkedList)
                if (color != ManaColor.BLUE)
                    textList += color.ToString().Substring(0, 1);
                else
                    textList += "U";

            return textList;
        }
    }
}
